home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / ISDAY_1.CMD < prev    next >
OS/2 REXX Batch file  |  1993-06-14  |  2KB  |  40 lines

  1. EXTPROC CEnvi
  2. /**********************************************************************
  3.  *** IsDay_1.cmd - Display message about whether it is The WeekDay  ***
  4.  ***               requested, and set ErrorLevel to 1 if it is else ***
  5.  ***               0 if it is not                                   ***
  6.  **********************************************************************/
  7.  
  8. main(argc,argv)
  9. {
  10.    IsDay = 0                           // Assume that it is not the correct day
  11.    if ( argc != 2  ||  strlen(argv[1]) < 3 ) {
  12.       // Invalid parameters were passed, and so explain how to use this program
  13.       ShowHelp()
  14.    } else {
  15.       TimeString = ctime(time())       // Standard C functions to get NOW as a string
  16.       strcpy(QueryDay,argv[1])         // copy first argument to work with it
  17.       QueryDay[3] = 0                  // limit to search on first three letters
  18.       // case-inensitive (i.e., both string converted to upper-case) search for
  19.       // QueryDay in TimeString
  20.       if strstr(strupr(TimeString),strupr(QueryDay)) {
  21.          printf("Yes, today is %s\n",argv[1])
  22.          IsDay = 1
  23.       } else
  24.          printf("No, today is not %s\n",argv[1])
  25.    }
  26.    return IsDay
  27. }
  28.  
  29. ShowHelp() // This routine is called above if input seems invalid
  30. {
  31.    printf("\n\a")      // This makes an audible beep
  32.    printf("IsDay.cmd - CMM program to check if it is a certain day of the week.\n")
  33.    printf("            Will print messages if it is or isn't, and return with\n")
  34.    printf("            ERRORLEVEL 1 if it is the requested day, and 0 if it is not.\n")
  35.    printf("            You must supply at least the first three letters of the day.\n")
  36.    printf("Example:\n")
  37.    printf("\tISDAY <Friday | Fri | FRI | FRICASSE>\n\n");
  38. }
  39.  
  40.